//
//  Matrix.h
//  Mockup
//
//  Created by Bernardo Quibiana on 3/26/10.
//  Copyright 2010 Mac-Easy@USC. All rights reserved.
//

#import <Foundation/Foundation.h>


@interface Matrix : NSObject {
	NSUInteger rowSize;
	NSUInteger colSize;
	NSMutableArray * core;
}
@property (nonatomic) NSUInteger rowSize;
@property (nonatomic) NSUInteger colSize;
@property (nonatomic, readonly) NSMutableArray * core;

/*
 * Initializing a matrix
 */
- (id)initWithMatrix: (Matrix *) matrix;
- (id)initWithMatrix:(Matrix *)matrix rowRange:(NSRange) rowRange colRange:(NSRange) colRange wrapAround:(BOOL) wrap;
- (id)initWithRowSize: (NSUInteger) rows colSize:(NSUInteger) cols;
- (id)initWithArray:(NSArray *) array rowSize:(NSUInteger) rows colSize:(NSUInteger) cols;
- (id)initWithContentsOfFile:(NSString *) path rowSize:(NSUInteger) rows colSize:(NSUInteger) cols;
- (id)initWithContentsOfURL:(NSURL *) url rowSize:(NSUInteger) rows colSize:(NSUInteger) cols;

/*
 * Creating a matrix
 */
+ (id)matrixWithMatrix:(Matrix *) matrix;
+ (id)matrixWithMatrix:(Matrix *)matrix rowRange:(NSRange) rowRange colRange:(NSRange) colRange wrapAround:(BOOL) wrap;
+ (id)matrixWithContentsOfArray:(NSArray *) array rowSize:(NSUInteger) rows colSize:(NSUInteger) cols;
+ (id)matrixWithContentsOfFile:(NSString *) path rowSize:(NSUInteger) rows colSize:(NSUInteger) cols;
+ (id)matrixWithContentsOfURL:(NSURL *) url rowSize:(NSUInteger) rows colSize:(NSUInteger) cols;

/*
 *  Querying a matrix
 */
- (BOOL)containsObject:(id) object;
- (void)getObjects:(id *) buffer;
- (void)getObjects:(id *) buffer row:(NSUInteger) row range:(NSRange) range;
- (void)getObjects:(id *) buffer col:(NSUInteger) col range:(NSRange) range;
- (void)getObjects:(id *) buffer indexRange:(NSRange) range;
- (id)objectAtIndex:(NSUInteger) index;
- (id)objectAtRow:(NSUInteger) row andCol:(NSUInteger) col;
- (NSArray *)getRow:(NSUInteger) row;
- (NSArray *)getCol:(NSUInteger) col;
- (NSEnumerator *)objectEnumerator;


/*
 * Finding objects in the matrix
 */
- (NSUInteger)indexOfObject:(id) object;
- (NSUInteger)indexOfObject:(id) object inRange:(NSRange) range;
- (NSUInteger)indexOfObjectIdenticalTo:(id) object;

/*
 * Inserting and replacing objects
 */
- (void)insertObject:(id)object atRow:(NSUInteger) row andCol:(NSUInteger) col; 
- (void)insertObject:(id)object atIndex:(NSUInteger) index;

- (void)replaceObjectAtRow:(NSUInteger) row andCol:(NSUInteger) col withObject:(id) object;
- (void)replaceObjectAtIndex:(NSUInteger) index withObject:(id) object;
- (void)replaceObjectsAtIndexes:(NSIndexSet *) indexes withObject:(id) object;

/*
 * Writing operations
 */
- (NSString *) description;
- (BOOL)writeToFile:(NSString *) path atomically:(BOOL) flag;
- (BOOL)writeToURL:(NSURL *) url atomically:(BOOL) flag;

@end
